﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Net;
using System.Net.Sockets;

namespace WxgjClient
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            var endpoit = new IPEndPoint(IPAddress.Parse("8.135.42.100"), 50001);
            client.Connect(endpoit);
            var dataStr = (cbDevice.SelectedItem as ComboBoxItem).Content.ToString() + "\r\n";
            var data = System.Text.Encoding.ASCII.GetBytes(dataStr);
            client.Send(data);
            client.Close();
            MessageBox.Show("打卡成功：" + (cbDevice.SelectedItem as ComboBoxItem).Content.ToString());
        }

        private void clear_pts(object sender, RoutedEventArgs e)
        {
            var req = (HttpWebRequest)WebRequest.Create("http://8.135.42.100:54432/clear");
            req.Method = "GET";
            var rsp = req.GetResponse();
            MessageBox.Show("重置成功！");
        }
    }
}
